package com.turing.post.webservice.impl;

import java.math.BigInteger;
import java.util.Hashtable;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import com.turing.post.datatranfer.util.CardkindBusiness;
import com.turing.post.datatranfer.util.OldIssueBranchBusiness;
import com.turing.post.datatranfer.util.OldSalebranchBusiness;
import com.turing.post.datatranfer.util.OldUserBusiness;
import com.turing.post.datatranferpmbs.util.OldMerchantBusiness;
import com.turing.post.util.PCPSApplicationException;
import com.turing.post.util.PCPSWebInput;


public class JcTest {
	/**
	 * @param args
	 * @throws InterruptedException 
	 */
	@SuppressWarnings("unchecked")
	public static void main(String[] args) throws InterruptedException {
		
		// 用户登录成功信息检测
		Context ctx = null;
		// 根据客户端传来的名字查找相应的实现EJB
		OldIssueBranchBusiness dao = null;
		String name = "datatranfer.impl.OldIssueBranchBusinessImpl" + "#"
				+ OldIssueBranchBusiness.class.getName();

		Hashtable env = new Hashtable();
		env.put(InitialContext.INITIAL_CONTEXT_FACTORY,
				"weblogic.jndi.WLInitialContextFactory");
		env.put(InitialContext.PROVIDER_URL, "t3://192.168.1.124:7001");

		try {
			ctx = new InitialContext(env);
		} catch (NamingException e1) {
			e1.printStackTrace();
		}
		try {
			dao = (OldIssueBranchBusiness) ctx.lookup(name);
		} catch (NamingException e) {
			e.printStackTrace();
		}
		
		String issuecompanyno = "961855";
		String cardManufactureId = "28"; 
		String regionNo="410101";
		String incomeBranchId="11";
		String developBranchNo="9618509961010125";
			System.out.println("开始了");
			try {
				PCPSWebInput webInput=new PCPSWebInput();
				webInput.setOperBranchNo("9618509961");
				webInput.setOperId(new BigInteger("9"));
				dao.insertNewIssueBranch(webInput, issuecompanyno, regionNo);
			} catch (PCPSApplicationException e) {
				e.printStackTrace();
			}
			System.out.println("结束了");
		
	}
    //卡种类
	private static void cardClass() throws InterruptedException{

		// 用户登录成功信息检测
		Context ctx = null;
		// 根据客户端传来的名字查找相应的实现EJB
		CardkindBusiness dao = null;
		String name = "datatranfer.impl.CardkindBusinessImpl" + "#"
				+ CardkindBusiness.class.getName();

		Hashtable env = new Hashtable();
		env.put(InitialContext.INITIAL_CONTEXT_FACTORY,
				"weblogic.jndi.WLInitialContextFactory");
		env.put(InitialContext.PROVIDER_URL, "t3://192.168.1.133:7001");

		try {
			ctx = new InitialContext(env);
		} catch (NamingException e1) {
			e1.printStackTrace();
		}
		try {
			dao = (CardkindBusiness) ctx.lookup(name);
		} catch (NamingException e) {
			e.printStackTrace();
		}
		
		String issuecompanyno = "981080";
		
			System.out.println("开始了");
			try {
				dao.insertCardClassic(issuecompanyno);
			} catch (PCPSApplicationException e) {
				e.printStackTrace();
			}
			System.out.println("结束了");
	}
	//商户
	private static void Match() throws InterruptedException{
		
		// 用户登录成功信息检测
		Context ctx = null;
		// 根据客户端传来的名字查找相应的实现EJB
		OldMerchantBusiness dao = null;
		String name = "datatranferpmbs.impl.OldMerchantBusinessImpl" + "#"
				+ OldMerchantBusiness.class.getName();

		Hashtable env = new Hashtable();
		env.put(InitialContext.INITIAL_CONTEXT_FACTORY,
				"weblogic.jndi.WLInitialContextFactory");
		env.put(InitialContext.PROVIDER_URL, "t3://192.168.1.133:7001");

		try {
			ctx = new InitialContext(env);
		} catch (NamingException e1) {
			e1.printStackTrace();
		}
		try {
			dao = (OldMerchantBusiness) ctx.lookup(name);
		} catch (NamingException e) {
			e.printStackTrace();
		}
		
		String issuecompanyno = "961850";
		String cardManufactureId = "28"; 
		String regionNo="61";
		String incomeBranchId="11";
		String developBranchNo="9618509961";
		
			System.out.println("开始了");
			try {
				PCPSWebInput webInput=new PCPSWebInput();
				webInput.setOperBranchNo("9618509961");
				webInput.setOperId(new BigInteger("9"));
				dao.insertNewMerchant(webInput, issuecompanyno, regionNo, incomeBranchId, developBranchNo);
			} catch (PCPSApplicationException e) {
				e.printStackTrace();
			}
			System.out.println("结束了");
	}
	//发卡机构
	private static void Issbranch() throws InterruptedException{
		
		// 用户登录成功信息检测
		Context ctx = null;
		// 根据客户端传来的名字查找相应的实现EJB
		OldIssueBranchBusiness dao = null;
		String name = "datatranfer.impl.OldIssueBranchBusinessImpl" + "#"
				+ OldIssueBranchBusiness.class.getName();

		Hashtable env = new Hashtable();
		env.put(InitialContext.INITIAL_CONTEXT_FACTORY,
				"weblogic.jndi.WLInitialContextFactory");
		env.put(InitialContext.PROVIDER_URL, "t3://192.168.1.133:7001");

		try {
			ctx = new InitialContext(env);
		} catch (NamingException e1) {
			e1.printStackTrace();
		}
		try {
			dao = (OldIssueBranchBusiness) ctx.lookup(name);
		} catch (NamingException e) {
			e.printStackTrace();
		}
		
		String issuecompanyno = "961850";
		String cardManufactureId = "28"; 
		String regionNo="410101";
		String incomeBranchId="11";
		String developBranchNo="9618509961010125";
			System.out.println("开始了");
			try {
				PCPSWebInput webInput=new PCPSWebInput();
				webInput.setOperBranchNo("9618509961");
				webInput.setOperId(new BigInteger("9"));
				dao.insertNewIssueBranch(webInput, issuecompanyno, regionNo);
			} catch (PCPSApplicationException e) {
				e.printStackTrace();
			}
			System.out.println("结束了");
	}
	//销售机构
	private static void Salebranch() throws InterruptedException{
		// 用户登录成功信息检测
		Context ctx = null;
		// 根据客户端传来的名字查找相应的实现EJB
		OldSalebranchBusiness dao = null;
		String name = "datatranfer.impl.OldSaleBranchBusinessImpl" + "#"
				+ OldSalebranchBusiness.class.getName();

		Hashtable env = new Hashtable();
		env.put(InitialContext.INITIAL_CONTEXT_FACTORY,
				"weblogic.jndi.WLInitialContextFactory");
		env.put(InitialContext.PROVIDER_URL, "t3://192.168.1.133:7001");

		try {
			ctx = new InitialContext(env);
		} catch (NamingException e1) {
			e1.printStackTrace();
		}
		try {
			dao = (OldSalebranchBusiness) ctx.lookup(name);
		} catch (NamingException e) {
			e.printStackTrace();
		}
		
		String issuecompanyno = "961850";
		String cardManufactureId = "28"; 
		String regionNo="410101";
		String incomeBranchId="11";
		String developBranchNo="9618509961010125";
		String issbranchno="96185041010100";
			System.out.println("开始了");
			try {
				PCPSWebInput webInput=new PCPSWebInput();
				webInput.setOperBranchNo("9618509961");
				webInput.setOperId(new BigInteger("9"));
				dao.insertNewSaleBranch(webInput, issuecompanyno, regionNo, issbranchno, incomeBranchId);
			} catch (PCPSApplicationException e) {
				e.printStackTrace();
			}
			System.out.println("结束了");
	}
	//用户
	private static void UserLogin() throws InterruptedException{
		// 用户登录成功信息检测
		Context ctx = null;
		// 根据客户端传来的名字查找相应的实现EJB
		OldUserBusiness dao = null;
		String name = "datatranfer.impl.OldUserBusinessImpll" + "#"
				+ OldUserBusiness.class.getName();

		Hashtable env = new Hashtable();
		env.put(InitialContext.INITIAL_CONTEXT_FACTORY,
				"weblogic.jndi.WLInitialContextFactory");
		env.put(InitialContext.PROVIDER_URL, "t3://192.168.1.133:7001");

		try {
			ctx = new InitialContext(env);
		} catch (NamingException e1) {
			e1.printStackTrace();
		}
		try {
			dao = (OldUserBusiness) ctx.lookup(name);
		} catch (NamingException e) {
			e.printStackTrace();
		}
		
		String issuecompanyno = "961850";
		String roleid = "3"; 
		String branchno="96185041010100";
			System.out.println("开始了");
			try {
				PCPSWebInput webInput=new PCPSWebInput();
				webInput.setOperBranchNo("961850");
				webInput.setOperId(new BigInteger("9"));
				dao.insertNewUser(webInput, branchno, issuecompanyno, roleid);
			} catch (PCPSApplicationException e) {
				e.printStackTrace();
			}
			System.out.println("结束了");
	}
}
